<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="java.util.List" %>
<%@ page import="epis.unsa.Alumno" %>
<%@ page import="epis.unsa.PMF" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user != null && user.getNickname().equals("alfredopaz7")){
	PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "select from " + Alumno.class.getName();
    List<Alumno> students = (List<Alumno>) pm.newQuery(query).execute();
    for(Alumno student: students)
    	pm.deletePersistent(student);
} else
	response.sendRedirect("login.jsp");
%>
<h1>Alumnos borrados</h1>
</body>
</html>